﻿using pdfer.FileObjects;
using pdfer.Syntax;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace pdfer.PdfObjecs.Fonts
{
    internal class EncodingDictionary : PdfFileObject
    {
        public EncodingDictionary(PdfFileObject pdfFileObject)
            : base(pdfFileObject)
        {
            if (pdfFileObject.TryGetValue(PdfName.Key_Type, out object? val))
            {
                Type = PdfParserUtils.ParseString(val);
                if (Type != PdfTypeConst.Type_Encoding)
                {
                    throw new Exception("类型必须是 /Encoding");
                }
            }
        }

        public string Type { get; set; }
        /// <summary>
        /// 
        /// </summary>
        public string Subtype { get; set; }

        /// <summary>
        /// MacRomanEncoding
        /// MacExpertEncoding
        /// WinAnsiEncoding
        /// </summary>
        public string BaseEncoding
        {
            get
            {
                return GetDicStringVal(PdfName.Key_BaseEncoding);
            }
        }
        /// <summary>
        /// （可选;不建议使用 TrueType 字体）一个数组，描述与 BaseEncoding 指定的编码的差异，如果不存在 BaseEncoding，则描述与隐式基本编码的差异。Differences 数组如下所述。
        /// </summary>
        public List<Object> Differences
        {
            get
            {
                return GetDicListVal(PdfName.Key_Differences);
            }
        }
    }
}
